home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Inne / Gry / Carnage_Contest / scripts / CC Original / tools / Bar.lua next >
Text File  |  2009-09-14  |  2KB  |  55 lines

  1. --------------------------------------------------------------------------------
  2. -- Weapon Bar
  3. -- Original Carnage Contest Weapon
  4. -- Script by DC, August 2009, www.UnrealSoftware.de
  5. --------------------------------------------------------------------------------
  6.  
  7. -- Setup Tables
  8. if cc==nil then cc={} end
  9. cc.bar={}
  10. cc.bar.gfx_wpn={}
  11.  
  12. -- Load & Prepare Ressources
  13. for i=0,3,1 do
  14.     cc.bar.gfx_wpn[i]=loadgfx("buildings/bar"..i..".bmp")                    -- Weapon Image
  15.     setmidhandle(cc.bar.gfx_wpn[i])
  16. end
  17. cc.bar.sfx_build=loadsfx("buildmetal.ogg")                                    -- Build Sound
  18.  
  19. --------------------------------------------------------------------------------
  20. -- Weapon: Bar
  21. --------------------------------------------------------------------------------
  22.  
  23. cc.bar.id=addweapon("cc.bar","Bar",cc.bar.gfx_wpn[0],3)                        -- Add Weapon (3 uses)
  24.  
  25. function cc.bar.draw()                                                        -- Draw
  26.     if weapon_shots==0 then
  27.         -- HUD Positioning
  28.         hudpositioning(pos_build,cc.bar.gfx_wpn[weapon_mode])
  29.         -- HUD Info
  30.         hudinfo("Press [Space] to rotate the bar!")
  31.     end
  32. end
  33.  
  34. function cc.bar.attack(attack)                                                -- Attack
  35.     if weapon_timer>0 then
  36.         weapon_timer=weapon_timer-1
  37.     end
  38.     if (weapon_shots<=0) and (attack==1) and (weapon_timer==0) then
  39.         -- Rotate
  40.         weapon_timer=15
  41.         weapon_mode=weapon_mode+1
  42.         if weapon_mode>3 then
  43.             weapon_mode=0
  44.         end
  45.     end
  46.     if (weapon_shots<=0) and (weapon_position==1) then
  47.         -- Use weapon and allow to use another one afterwards (1)
  48.         useweapon(1)
  49.         weapon_shots=weapon_shots+1
  50.         -- Draw
  51.         terrainimage(cc.bar.gfx_wpn[weapon_mode],weapon_x,weapon_y)
  52.         -- Sound
  53.         playsound(cc.bar.sfx_build)
  54.     end
  55. end